package com.qf.base.controller;

import com.qf.base.domain.BaseVehicle;
import com.qf.base.service.IBaseVehicleService;
import com.qf.common.annotation.Log;
import com.qf.common.core.controller.BaseController;
import com.qf.common.core.domain.AjaxResult;
import com.qf.common.core.page.TableDataInfo;
import com.qf.common.enums.BusinessType;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * --- ONE PIECE ---
 *
 * @author yangjiangcheng
 * @date 2025/9/3
 * @desc
 */
@RestController
@RequestMapping("/tms/base/vehicle")
public class BaseVehicleController extends BaseController{
    @Autowired
    private IBaseVehicleService baseVehicleService;

    /**
     * 查询车辆信息列表
     */
    @GetMapping("/list")
    public TableDataInfo list(BaseVehicle baseVehicle) {
        startPage();
        List<BaseVehicle> list = baseVehicleService.selectVehicleList(baseVehicle);
        return getDataTable(list);
    }

    /**
     * 新增车辆信息
     */
    @Log(title = "车辆管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody BaseVehicle baseVehicle) {
        return toAjax(baseVehicleService.insertVehicle(baseVehicle));
    }

    /**
     * 获取车辆信息详细信息
     */
    @GetMapping(value = "/{vehicleId}")
    public AjaxResult getInfo(@PathVariable("vehicleId") Long vehicleId) {
        return AjaxResult.success(baseVehicleService.selectVehicleById(vehicleId));
    }

    /**
     * 修改车辆信息
     */
    @Log(title = "车辆管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody BaseVehicle baseVehicle) {
        return toAjax(baseVehicleService.updateVehicle(baseVehicle));
    }

    @Log(title = "车辆管理", businessType = BusinessType.DELETE)
    @DeleteMapping("/{vehicleIds}")
    public AjaxResult remove(@PathVariable Long[] vehicleIds) {
        return toAjax(baseVehicleService.deleteVehicleByIds(vehicleIds));
    }


}
